<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<html>
  <head>  
    <title>My JSP 'scar.jsp' starting page</title>
  </head>
  
  <body>
  
  	<select id="car" onchange="selectCar()">
  		<option value="">-- 请选择 汽车--</option>
    	<option value="bmw">宝马</option>
    	<option value="audi">奥迪</option>
    	<option value="benz">奔驰</option>
  	</select>
  	
  	<select id="type">
  		<option value="">-- 请选择系列 --</option>
  	</select>
  	
  	
  	<script type="text/javascript">
  		function selectCar(){
  			var cararray=new Array();
  			cararray['bmw']=["521","621","721","821"];
  			cararray['audi']=["A1","A2","A3","A4","A5","A6"];
  			cararray['benz']=["B1","B2","B3","B4"];
  			
  			var c=document.getElementById("car").value;
  			if(c!=""){
  				document.getElementById("type").options.length = 1;
  				for(var i in cararray[c]){
  					var type=cararray[c][i];
  					var option=new Option(type,type);
  					
  					document.getElementById("type").options.add(option);
  				}
  			}
  		}

	</script>
  
  </body>
</html>
